package org.liuyunfeng.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * @author: TanJingyu
 * @create: 2022-06-21 14:41
 **/
@RestController
@RequestMapping("/cyclicBarrier")
public class CyclicBarrierController {
    private final CyclicBarrier cyclicBarrier = new CyclicBarrier(2);

    @GetMapping
    public Object a() throws BrokenBarrierException, InterruptedException {
        System.out.println(Thread.currentThread().getName());
        cyclicBarrier.await();
        System.out.println("哈哈");
        return cyclicBarrier.getParties();
    }
}

    